package com.qn.knife4j;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import com.github.xiaoymin.knife4j.spring.configuration.Knife4jProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * @description:
 * @author: xiongzhilong
 * @time: 2021/4/20 9:52
 */
@EnableOpenApi
@Configuration
@EnableKnife4j
@EnableConfigurationProperties(value = {Knife4jProperties.class})
public class Knife4jConfiguration {

    /**
     * 后台API信息
     */
    private ApiInfo backApiInfo() {
        return new ApiInfoBuilder()
                .build();
    }

    /**
     * 后台API
     */
    @Bean
    public Docket backApi() {
        return new Docket(DocumentationType.OAS_30)
                .apiInfo(backApiInfo())
                //.pathMapping("/opt")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.qn"))
                .paths(PathSelectors.any())
                .build();
    }
}
